import os
progname='luoding4'
saoma_port = 51236
saoma_ip = '192.168.1.150'
plc_ip = '192.168.1.20'

confdef = {
    #thd_conf
    'kakouok': ['thd_conf', 50, 0, 100, 'ok阈值'],
    'kakoung': ['thd_conf', 60, 0, 100, 'ng阈值'],
    'luodingscore': ['thd_conf', 40, 0, 100, '螺钉得分阈值'],
    'luodingroi': ['thd_conf', 40, 0, 100, '螺钉roi'],
    'minrets': ['thd_conf', 4, 0, 10, '最少图片数'],

    #chk_conf 
    'stopline': ['chk_conf', 0, '开启停线'],
    'scadastopline': ['chk_conf', 0, '开启scada停线'],
    'use_scada': ['chk_conf', 0, '开启scada'],
    'detect_dianji': ['chk_conf', 1, '检测电机'],
}

camnames_ips = [
    '1.电机螺钉 0 192.168.1.105 ptcluoding',
]


def jiaodu_trans(x):
    x = x.replace('逆', '-').replace('顺', '+')
    x = int(x)
    return x

camnames_ips = [s.split() for s in camnames_ips]
camnames = [s[0] for s in camnames_ips]
id2index = {}
for index, x in enumerate(camnames):
    id = x.split('.')[0]
    id2index[id] = index
cam_rot = [jiaodu_trans(s[1]) for s in camnames_ips]
cam_ips = [s[2].split('.')[-1] for s in camnames_ips]
quexians = [s[3].split('+') for s in camnames_ips]

config = {
    "captype": "hk",
    'password': '',
    'ips': cam_ips,
    'camnames': camnames,
    "stopline_time": 15,
    "ncams": 1,
    "usbcamid": 1,
    "oktext": "12345",
    "comid": "COM3",
    "saveimg": 1,
    "onlycapimg": 0,
    "stopline": 1,
    'conf_thres': 0.4,
    'iou_thres': 0.1,
    'crop_num': 3,
    'imgsz': 512,
    'qutu_num': 8,
    'kakouok': 50,
    'kakoung': 60,
    'classname': '装配结构检验',
}


pa = 'D:/data/220401小鸟/'
pa = 'D:/data/220401小鸟/220609/PO69051不良'
pa = 'D:/data/220401小鸟/220803不良品'
pa = 'D:/data/221101电机螺钉/nei1_luoding4'
pa = 'D:/data/221101电机螺钉/nei1_luoding4/_add_imgs/221017新建文件夹'
pa = 'D:/data/221101电机螺钉/test/0507a'
pa = 'D:/data/221101电机螺钉/test/0411/手动测试  未报警未/20230411_091731_739_5112239640934110310118_0/aa'
pa = 'D:/data/221101电机螺钉/test/20230509_2'
pa = 'D:/data/221101电机螺钉/test/20230509新建文件夹'
pa = 'D:/data/221101电机螺钉/test/20230508_175854新建文件夹'
pa = pa if os.path.exists(pa) else 'E:/OK/camera3/2022-10-17/511223963132A170310138'


pp = {
    '105':f'{pa}',
}
